<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">

<html lang="en">

<head>
  <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
  <title>LCOV - Lua 5.2.4 - src/lobject.c</title>
  <link rel="stylesheet" type="text/css" href="../gcov.css">
</head>

<body>

  <table width="100%" border=0 cellspacing=0 cellpadding=0>
    <tr><td class="title">LCOV - code coverage report</td></tr>
    <tr><td class="ruler"><img src="../glass.png" width=3 height=3 alt=""></td></tr>

    <tr>
      <td width="100%">
        <table cellpadding=1 border=0 width="100%">
          <tr>
            <td width="10%" class="headerItem">Current view:</td>
            <td width="35%" class="headerValue"><a href="../index.html">top level</a> - <a href="index.html">src</a> - lobject.c</td>
            <td width="5%"></td>
            <td width="15%"></td>
            <td width="10%" class="headerCovTableHead">Hit</td>
            <td width="10%" class="headerCovTableHead">Total</td>
            <td width="15%" class="headerCovTableHead">Coverage</td>
          </tr>
          <tr>
            <td class="headerItem">Test:</td>
            <td class="headerValue">Lua 5.2.4</td>
            <td></td>
            <td class="headerItem">Lines:</td>
            <td class="headerCovTableEntry">96</td>
            <td class="headerCovTableEntry">109</td>
            <td class="headerCovTableEntryMed">88.1 %</td>
          </tr>
          <tr>
            <td class="headerItem">Date:</td>
            <td class="headerValue">2019-06-13 19:44:16</td>
            <td></td>
          </tr>
          <tr>
            <td class="headerItem">Legend:</td>
            <td class="headerValueLeg">            Lines:
            <span class="coverLegendCov">hit</span>
            <span class="coverLegendNoCov">not hit</span>
</td>
            <td></td>
          </tr>
          <tr><td><img src="../glass.png" width=3 height=3 alt=""></td></tr>
        </table>
      </td>
    </tr>

    <tr><td class="ruler"><img src="../glass.png" width=3 height=3 alt=""></td></tr>
  </table>

  <table cellpadding=0 cellspacing=0 border=0>
    <tr>
      <td><br></td>
    </tr>
    <tr>
      <td>
<pre class="sourceHeading">          Line data    Source code</pre>
<pre class="source">
<span class="lineNum">       1 </span>            : /*
<span class="lineNum">       2 </span>            : ** $Id: lobject.c,v 2.58.1.1 2013/04/12 18:48:47 roberto Exp $
<span class="lineNum">       3 </span>            : ** Some generic functions over Lua objects
<span class="lineNum">       4 </span>            : ** See Copyright Notice in lua.h
<span class="lineNum">       5 </span>            : */
<span class="lineNum">       6 </span>            : 
<span class="lineNum">       7 </span>            : #include &lt;stdarg.h&gt;
<span class="lineNum">       8 </span>            : #include &lt;stdio.h&gt;
<span class="lineNum">       9 </span>            : #include &lt;stdlib.h&gt;
<span class="lineNum">      10 </span>            : #include &lt;string.h&gt;
<span class="lineNum">      11 </span>            : 
<span class="lineNum">      12 </span>            : #define lobject_c
<span class="lineNum">      13 </span>            : #define LUA_CORE
<span class="lineNum">      14 </span>            : 
<span class="lineNum">      15 </span>            : #include &quot;lua.h&quot;
<span class="lineNum">      16 </span>            : 
<span class="lineNum">      17 </span>            : #include &quot;lctype.h&quot;
<span class="lineNum">      18 </span>            : #include &quot;ldebug.h&quot;
<span class="lineNum">      19 </span>            : #include &quot;ldo.h&quot;
<span class="lineNum">      20 </span>            : #include &quot;lmem.h&quot;
<span class="lineNum">      21 </span>            : #include &quot;lobject.h&quot;
<span class="lineNum">      22 </span>            : #include &quot;lstate.h&quot;
<span class="lineNum">      23 </span>            : #include &quot;lstring.h&quot;
<span class="lineNum">      24 </span>            : #include &quot;lvm.h&quot;
<span class="lineNum">      25 </span>            : 
<span class="lineNum">      26 </span>            : 
<span class="lineNum">      27 </span>            : 
<span class="lineNum">      28 </span>            : LUAI_DDEF const TValue luaO_nilobject_ = {NILCONSTANT};
<span class="lineNum">      29 </span>            : 
<span class="lineNum">      30 </span>            : 
<span class="lineNum">      31 </span>            : /*
<span class="lineNum">      32 </span>            : ** converts an integer to a &quot;floating point byte&quot;, represented as
<span class="lineNum">      33 </span>            : ** (eeeeexxx), where the real value is (1xxx) * 2^(eeeee - 1) if
<span class="lineNum">      34 </span>            : ** eeeee != 0 and (xxx) otherwise.
<span class="lineNum">      35 </span>            : */
<span class="lineNum">      36 </span><span class="lineCov">       1352 : int luaO_int2fb (unsigned int x) {</span>
<span class="lineNum">      37 </span><span class="lineCov">       1352 :   int e = 0;  /* exponent */</span>
<span class="lineNum">      38 </span><span class="lineCov">       1352 :   if (x &lt; 8) return x;</span>
<span class="lineNum">      39 </span><span class="lineCov">         12 :   while (x &gt;= 0x10) {</span>
<span class="lineNum">      40 </span><span class="lineCov">          7 :     x = (x+1) &gt;&gt; 1;</span>
<span class="lineNum">      41 </span><span class="lineCov">          7 :     e++;</span>
<span class="lineNum">      42 </span>            :   }
<span class="lineNum">      43 </span><span class="lineCov">          5 :   return ((e+1) &lt;&lt; 3) | (cast_int(x) - 8);</span>
<span class="lineNum">      44 </span>            : }
<span class="lineNum">      45 </span>            : 
<span class="lineNum">      46 </span>            : 
<span class="lineNum">      47 </span>            : /* converts back */
<span class="lineNum">      48 </span><span class="lineCov">        500 : int luaO_fb2int (int x) {</span>
<span class="lineNum">      49 </span><span class="lineCov">        500 :   int e = (x &gt;&gt; 3) &amp; 0x1f;</span>
<span class="lineNum">      50 </span><span class="lineCov">        500 :   if (e == 0) return x;</span>
<span class="lineNum">      51 </span><span class="lineCov">          5 :   else return ((x &amp; 7) + 8) &lt;&lt; (e - 1);</span>
<span class="lineNum">      52 </span>            : }
<span class="lineNum">      53 </span>            : 
<span class="lineNum">      54 </span>            : 
<span class="lineNum">      55 </span><span class="lineCov">      36792 : int luaO_ceillog2 (unsigned int x) {</span>
<span class="lineNum">      56 </span>            :   static const lu_byte log_2[256] = {
<span class="lineNum">      57 </span>            :     0,1,2,2,3,3,3,3,4,4,4,4,4,4,4,4,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,
<span class="lineNum">      58 </span>            :     6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,
<span class="lineNum">      59 </span>            :     7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,
<span class="lineNum">      60 </span>            :     7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,
<span class="lineNum">      61 </span>            :     8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,
<span class="lineNum">      62 </span>            :     8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,
<span class="lineNum">      63 </span>            :     8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,
<span class="lineNum">      64 </span>            :     8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8
<span class="lineNum">      65 </span>            :   };
<span class="lineNum">      66 </span><span class="lineCov">      36792 :   int l = 0;</span>
<span class="lineNum">      67 </span><span class="lineCov">      36792 :   x--;</span>
<span class="lineNum">      68 </span><span class="lineCov">      36885 :   while (x &gt;= 256) { l += 8; x &gt;&gt;= 8; }</span>
<span class="lineNum">      69 </span><span class="lineCov">      36792 :   return l + log_2[x];</span>
<span class="lineNum">      70 </span>            : }
<span class="lineNum">      71 </span>            : 
<span class="lineNum">      72 </span>            : 
<span class="lineNum">      73 </span><span class="lineCov">         46 : lua_Number luaO_arith (int op, lua_Number v1, lua_Number v2) {</span>
<span class="lineNum">      74 </span><span class="lineCov">         46 :   switch (op) {</span>
<span class="lineNum">      75 </span><span class="lineCov">         10 :     case LUA_OPADD: return luai_numadd(NULL, v1, v2);</span>
<span class="lineNum">      76 </span><span class="lineCov">          6 :     case LUA_OPSUB: return luai_numsub(NULL, v1, v2);</span>
<span class="lineNum">      77 </span><span class="lineCov">         11 :     case LUA_OPMUL: return luai_nummul(NULL, v1, v2);</span>
<span class="lineNum">      78 </span><span class="lineCov">          7 :     case LUA_OPDIV: return luai_numdiv(NULL, v1, v2);</span>
<span class="lineNum">      79 </span><span class="lineCov">          5 :     case LUA_OPMOD: return luai_nummod(NULL, v1, v2);</span>
<span class="lineNum">      80 </span><span class="lineCov">          6 :     case LUA_OPPOW: return luai_numpow(NULL, v1, v2);</span>
<span class="lineNum">      81 </span><span class="lineCov">          1 :     case LUA_OPUNM: return luai_numunm(NULL, v1);</span>
<span class="lineNum">      82 </span><span class="lineNoCov">          0 :     default: lua_assert(0); return 0;</span>
<span class="lineNum">      83 </span>            :   }
<span class="lineNum">      84 </span>            : }
<span class="lineNum">      85 </span>            : 
<span class="lineNum">      86 </span>            : 
<span class="lineNum">      87 </span><span class="lineCov">         84 : int luaO_hexavalue (int c) {</span>
<span class="lineNum">      88 </span><span class="lineCov">         84 :   if (lisdigit(c)) return c - '0';</span>
<span class="lineNum">      89 </span><span class="lineCov">         30 :   else return ltolower(c) - 'a' + 10;</span>
<span class="lineNum">      90 </span>            : }
<span class="lineNum">      91 </span>            : 
<span class="lineNum">      92 </span>            : 
<span class="lineNum">      93 </span>            : #if !defined(lua_strx2number)
<span class="lineNum">      94 </span>            : 
<span class="lineNum">      95 </span>            : #include &lt;math.h&gt;
<span class="lineNum">      96 </span>            : 
<span class="lineNum">      97 </span>            : 
<span class="lineNum">      98 </span>            : static int isneg (const char **s) {
<span class="lineNum">      99 </span>            :   if (**s == '-') { (*s)++; return 1; }
<span class="lineNum">     100 </span>            :   else if (**s == '+') (*s)++;
<span class="lineNum">     101 </span>            :   return 0;
<span class="lineNum">     102 </span>            : }
<span class="lineNum">     103 </span>            : 
<span class="lineNum">     104 </span>            : 
<span class="lineNum">     105 </span>            : static lua_Number readhexa (const char **s, lua_Number r, int *count) {
<span class="lineNum">     106 </span>            :   for (; lisxdigit(cast_uchar(**s)); (*s)++) {  /* read integer part */
<span class="lineNum">     107 </span>            :     r = (r * cast_num(16.0)) + cast_num(luaO_hexavalue(cast_uchar(**s)));
<span class="lineNum">     108 </span>            :     (*count)++;
<span class="lineNum">     109 </span>            :   }
<span class="lineNum">     110 </span>            :   return r;
<span class="lineNum">     111 </span>            : }
<span class="lineNum">     112 </span>            : 
<span class="lineNum">     113 </span>            : 
<span class="lineNum">     114 </span>            : /*
<span class="lineNum">     115 </span>            : ** convert an hexadecimal numeric string to a number, following
<span class="lineNum">     116 </span>            : ** C99 specification for 'strtod'
<span class="lineNum">     117 </span>            : */
<span class="lineNum">     118 </span>            : static lua_Number lua_strx2number (const char *s, char **endptr) {
<span class="lineNum">     119 </span>            :   lua_Number r = 0.0;
<span class="lineNum">     120 </span>            :   int e = 0, i = 0;
<span class="lineNum">     121 </span>            :   int neg = 0;  /* 1 if number is negative */
<span class="lineNum">     122 </span>            :   *endptr = cast(char *, s);  /* nothing is valid yet */
<span class="lineNum">     123 </span>            :   while (lisspace(cast_uchar(*s))) s++;  /* skip initial spaces */
<span class="lineNum">     124 </span>            :   neg = isneg(&amp;s);  /* check signal */
<span class="lineNum">     125 </span>            :   if (!(*s == '0' &amp;&amp; (*(s + 1) == 'x' || *(s + 1) == 'X')))  /* check '0x' */
<span class="lineNum">     126 </span>            :     return 0.0;  /* invalid format (no '0x') */
<span class="lineNum">     127 </span>            :   s += 2;  /* skip '0x' */
<span class="lineNum">     128 </span>            :   r = readhexa(&amp;s, r, &amp;i);  /* read integer part */
<span class="lineNum">     129 </span>            :   if (*s == '.') {
<span class="lineNum">     130 </span>            :     s++;  /* skip dot */
<span class="lineNum">     131 </span>            :     r = readhexa(&amp;s, r, &amp;e);  /* read fractional part */
<span class="lineNum">     132 </span>            :   }
<span class="lineNum">     133 </span>            :   if (i == 0 &amp;&amp; e == 0)
<span class="lineNum">     134 </span>            :     return 0.0;  /* invalid format (no digit) */
<span class="lineNum">     135 </span>            :   e *= -4;  /* each fractional digit divides value by 2^-4 */
<span class="lineNum">     136 </span>            :   *endptr = cast(char *, s);  /* valid up to here */
<span class="lineNum">     137 </span>            :   if (*s == 'p' || *s == 'P') {  /* exponent part? */
<span class="lineNum">     138 </span>            :     int exp1 = 0;
<span class="lineNum">     139 </span>            :     int neg1;
<span class="lineNum">     140 </span>            :     s++;  /* skip 'p' */
<span class="lineNum">     141 </span>            :     neg1 = isneg(&amp;s);  /* signal */
<span class="lineNum">     142 </span>            :     if (!lisdigit(cast_uchar(*s)))
<span class="lineNum">     143 </span>            :       goto ret;  /* must have at least one digit */
<span class="lineNum">     144 </span>            :     while (lisdigit(cast_uchar(*s)))  /* read exponent */
<span class="lineNum">     145 </span>            :       exp1 = exp1 * 10 + *(s++) - '0';
<span class="lineNum">     146 </span>            :     if (neg1) exp1 = -exp1;
<span class="lineNum">     147 </span>            :     e += exp1;
<span class="lineNum">     148 </span>            :   }
<span class="lineNum">     149 </span>            :   *endptr = cast(char *, s);  /* valid up to here */
<span class="lineNum">     150 </span>            :  ret:
<span class="lineNum">     151 </span>            :   if (neg) r = -r;
<span class="lineNum">     152 </span>            :   return l_mathop(ldexp)(r, e);
<span class="lineNum">     153 </span>            : }
<span class="lineNum">     154 </span>            : 
<span class="lineNum">     155 </span>            : #endif
<span class="lineNum">     156 </span>            : 
<span class="lineNum">     157 </span>            : 
<span class="lineNum">     158 </span><span class="lineCov">       3192 : int luaO_str2d (const char *s, size_t len, lua_Number *result) {</span>
<span class="lineNum">     159 </span>            :   char *endptr;
<span class="lineNum">     160 </span><span class="lineCov">       3192 :   if (strpbrk(s, &quot;nN&quot;))  /* reject 'inf' and 'nan' */</span>
<span class="lineNum">     161 </span><span class="lineNoCov">          0 :     return 0;</span>
<span class="lineNum">     162 </span><span class="lineCov">       3192 :   else if (strpbrk(s, &quot;xX&quot;))  /* hexa? */</span>
<span class="lineNum">     163 </span><span class="lineCov">         99 :     *result = lua_strx2number(s, &amp;endptr);</span>
<span class="lineNum">     164 </span>            :   else
<span class="lineNum">     165 </span><span class="lineCov">       3093 :     *result = lua_str2number(s, &amp;endptr);</span>
<span class="lineNum">     166 </span><span class="lineCov">       3192 :   if (endptr == s) return 0;  /* nothing recognized */</span>
<span class="lineNum">     167 </span><span class="lineCov">       3172 :   while (lisspace(cast_uchar(*endptr))) endptr++;</span>
<span class="lineNum">     168 </span><span class="lineCov">       3170 :   return (endptr == s + len);  /* OK if no trailing characters */</span>
<span class="lineNum">     169 </span>            : }
<span class="lineNum">     170 </span>            : 
<span class="lineNum">     171 </span>            : 
<span class="lineNum">     172 </span>            : 
<span class="lineNum">     173 </span><span class="lineCov">       8067 : static void pushstr (lua_State *L, const char *str, size_t l) {</span>
<span class="lineNum">     174 </span><span class="lineCov">       8067 :   setsvalue2s(L, L-&gt;top++, luaS_newlstr(L, str, l));</span>
<span class="lineNum">     175 </span><span class="lineCov">       8067 : }</span>
<span class="lineNum">     176 </span>            : 
<span class="lineNum">     177 </span>            : 
<span class="lineNum">     178 </span>            : /* this function handles only `%d', `%c', %f, %p, and `%s' formats */
<span class="lineNum">     179 </span><span class="lineCov">       2147 : const char *luaO_pushvfstring (lua_State *L, const char *fmt, va_list argp) {</span>
<span class="lineNum">     180 </span><span class="lineCov">       2147 :   int n = 0;</span>
<span class="lineNum">     181 </span><span class="lineCov">       3149 :   for (;;) {</span>
<span class="lineNum">     182 </span><span class="lineCov">       5296 :     const char *e = strchr(fmt, '%');</span>
<span class="lineNum">     183 </span><span class="lineCov">       5296 :     if (e == NULL) break;</span>
<span class="lineNum">     184 </span><span class="lineCov">       3149 :     luaD_checkstack(L, 2);  /* fmt + item */</span>
<span class="lineNum">     185 </span><span class="lineCov">       3149 :     pushstr(L, fmt, e - fmt);</span>
<span class="lineNum">     186 </span><span class="lineCov">       3149 :     switch (*(e+1)) {</span>
<span class="lineNum">     187 </span><span class="lineCov">       2738 :       case 's': {</span>
<span class="lineNum">     188 </span><span class="lineCov">       2738 :         const char *s = va_arg(argp, char *);</span>
<span class="lineNum">     189 </span><span class="lineCov">       2738 :         if (s == NULL) s = &quot;(null)&quot;;</span>
<span class="lineNum">     190 </span><span class="lineCov">       2738 :         pushstr(L, s, strlen(s));</span>
<span class="lineNum">     191 </span><span class="lineCov">       2738 :         break;</span>
<span class="lineNum">     192 </span>            :       }
<span class="lineNum">     193 </span><span class="lineCov">         15 :       case 'c': {</span>
<span class="lineNum">     194 </span>            :         char buff;
<span class="lineNum">     195 </span><span class="lineCov">         15 :         buff = cast(char, va_arg(argp, int));</span>
<span class="lineNum">     196 </span><span class="lineCov">         15 :         pushstr(L, &amp;buff, 1);</span>
<span class="lineNum">     197 </span><span class="lineCov">         15 :         break;</span>
<span class="lineNum">     198 </span>            :       }
<span class="lineNum">     199 </span><span class="lineCov">        378 :       case 'd': {</span>
<span class="lineNum">     200 </span><span class="lineCov">        378 :         setnvalue(L-&gt;top++, cast_num(va_arg(argp, int)));</span>
<span class="lineNum">     201 </span><span class="lineCov">        378 :         break;</span>
<span class="lineNum">     202 </span>            :       }
<span class="lineNum">     203 </span><span class="lineNoCov">          0 :       case 'f': {</span>
<span class="lineNum">     204 </span><span class="lineNoCov">          0 :         setnvalue(L-&gt;top++, cast_num(va_arg(argp, l_uacNumber)));</span>
<span class="lineNum">     205 </span><span class="lineNoCov">          0 :         break;</span>
<span class="lineNum">     206 </span>            :       }
<span class="lineNum">     207 </span><span class="lineCov">         12 :       case 'p': {</span>
<span class="lineNum">     208 </span>            :         char buff[4*sizeof(void *) + 8]; /* should be enough space for a `%p' */
<span class="lineNum">     209 </span><span class="lineCov">         12 :         int l = sprintf(buff, &quot;%p&quot;, va_arg(argp, void *));</span>
<span class="lineNum">     210 </span><span class="lineCov">         12 :         pushstr(L, buff, l);</span>
<span class="lineNum">     211 </span><span class="lineCov">         12 :         break;</span>
<span class="lineNum">     212 </span>            :       }
<span class="lineNum">     213 </span><span class="lineCov">          6 :       case '%': {</span>
<span class="lineNum">     214 </span><span class="lineCov">          6 :         pushstr(L, &quot;%&quot;, 1);</span>
<span class="lineNum">     215 </span><span class="lineCov">          6 :         break;</span>
<span class="lineNum">     216 </span>            :       }
<span class="lineNum">     217 </span><span class="lineNoCov">          0 :       default: {</span>
<span class="lineNum">     218 </span><span class="lineNoCov">          0 :         luaG_runerror(L,</span>
<span class="lineNum">     219 </span>            :             &quot;invalid option &quot; LUA_QL(&quot;%%%c&quot;) &quot; to &quot; LUA_QL(&quot;lua_pushfstring&quot;),
<span class="lineNum">     220 </span><span class="lineNoCov">          0 :             *(e + 1));</span>
<span class="lineNum">     221 </span>            :       }
<span class="lineNum">     222 </span>            :     }
<span class="lineNum">     223 </span><span class="lineCov">       3149 :     n += 2;</span>
<span class="lineNum">     224 </span><span class="lineCov">       3149 :     fmt = e+2;</span>
<span class="lineNum">     225 </span>            :   }
<span class="lineNum">     226 </span><span class="lineCov">       2147 :   luaD_checkstack(L, 1);</span>
<span class="lineNum">     227 </span><span class="lineCov">       2147 :   pushstr(L, fmt, strlen(fmt));</span>
<span class="lineNum">     228 </span><span class="lineCov">       2147 :   if (n &gt; 0) luaV_concat(L, n + 1);</span>
<span class="lineNum">     229 </span><span class="lineCov">       2147 :   return svalue(L-&gt;top - 1);</span>
<span class="lineNum">     230 </span>            : }
<span class="lineNum">     231 </span>            : 
<span class="lineNum">     232 </span>            : 
<span class="lineNum">     233 </span><span class="lineCov">        319 : const char *luaO_pushfstring (lua_State *L, const char *fmt, ...) {</span>
<span class="lineNum">     234 </span>            :   const char *msg;
<span class="lineNum">     235 </span>            :   va_list argp;
<span class="lineNum">     236 </span><span class="lineCov">        319 :   va_start(argp, fmt);</span>
<span class="lineNum">     237 </span><span class="lineCov">        319 :   msg = luaO_pushvfstring(L, fmt, argp);</span>
<span class="lineNum">     238 </span><span class="lineCov">        319 :   va_end(argp);</span>
<span class="lineNum">     239 </span><span class="lineCov">        319 :   return msg;</span>
<span class="lineNum">     240 </span>            : }
<span class="lineNum">     241 </span>            : 
<span class="lineNum">     242 </span>            : 
<span class="lineNum">     243 </span>            : /* number of chars of a literal string without the ending \0 */
<span class="lineNum">     244 </span>            : #define LL(x)   (sizeof(x)/sizeof(char) - 1)
<span class="lineNum">     245 </span>            : 
<span class="lineNum">     246 </span>            : #define RETS    &quot;...&quot;
<span class="lineNum">     247 </span>            : #define PRE     &quot;[string \&quot;&quot;
<span class="lineNum">     248 </span>            : #define POS     &quot;\&quot;]&quot;
<span class="lineNum">     249 </span>            : 
<span class="lineNum">     250 </span>            : #define addstr(a,b,l)   ( memcpy(a,b,(l) * sizeof(char)), a += (l) )
<span class="lineNum">     251 </span>            : 
<span class="lineNum">     252 </span><span class="lineCov">        390 : void luaO_chunkid (char *out, const char *source, size_t bufflen) {</span>
<span class="lineNum">     253 </span><span class="lineCov">        390 :   size_t l = strlen(source);</span>
<span class="lineNum">     254 </span><span class="lineCov">        390 :   if (*source == '=') {  /* 'literal' source */</span>
<span class="lineNum">     255 </span><span class="lineCov">         67 :     if (l &lt;= bufflen)  /* small enough? */</span>
<span class="lineNum">     256 </span><span class="lineCov">         67 :       memcpy(out, source + 1, l * sizeof(char));</span>
<span class="lineNum">     257 </span>            :     else {  /* truncate it */
<span class="lineNum">     258 </span><span class="lineNoCov">          0 :       addstr(out, source + 1, bufflen - 1);</span>
<span class="lineNum">     259 </span><span class="lineNoCov">          0 :       *out = '\0';</span>
<span class="lineNum">     260 </span>            :     }
<span class="lineNum">     261 </span>            :   }
<span class="lineNum">     262 </span><span class="lineCov">        323 :   else if (*source == '@') {  /* file name */</span>
<span class="lineNum">     263 </span><span class="lineCov">        287 :     if (l &lt;= bufflen)  /* small enough? */</span>
<span class="lineNum">     264 </span><span class="lineCov">        287 :       memcpy(out, source + 1, l * sizeof(char));</span>
<span class="lineNum">     265 </span>            :     else {  /* add '...' before rest of name */
<span class="lineNum">     266 </span><span class="lineNoCov">          0 :       addstr(out, RETS, LL(RETS));</span>
<span class="lineNum">     267 </span><span class="lineNoCov">          0 :       bufflen -= LL(RETS);</span>
<span class="lineNum">     268 </span><span class="lineNoCov">          0 :       memcpy(out, source + 1 + l - bufflen, bufflen * sizeof(char));</span>
<span class="lineNum">     269 </span>            :     }
<span class="lineNum">     270 </span>            :   }
<span class="lineNum">     271 </span>            :   else {  /* string; format as [string &quot;source&quot;] */
<span class="lineNum">     272 </span><span class="lineCov">         36 :     const char *nl = strchr(source, '\n');  /* find first new line (if any) */</span>
<span class="lineNum">     273 </span><span class="lineCov">         36 :     addstr(out, PRE, LL(PRE));  /* add prefix */</span>
<span class="lineNum">     274 </span><span class="lineCov">         36 :     bufflen -= LL(PRE RETS POS) + 1;  /* save space for prefix+suffix+'\0' */</span>
<span class="lineNum">     275 </span><span class="lineCov">         36 :     if (l &lt; bufflen &amp;&amp; nl == NULL) {  /* small one-line source? */</span>
<span class="lineNum">     276 </span><span class="lineCov">         26 :       addstr(out, source, l);  /* keep it */</span>
<span class="lineNum">     277 </span>            :     }
<span class="lineNum">     278 </span>            :     else {
<span class="lineNum">     279 </span><span class="lineCov">         10 :       if (nl != NULL) l = nl - source;  /* stop at first newline */</span>
<span class="lineNum">     280 </span><span class="lineCov">         10 :       if (l &gt; bufflen) l = bufflen;</span>
<span class="lineNum">     281 </span><span class="lineCov">         10 :       addstr(out, source, l);</span>
<span class="lineNum">     282 </span><span class="lineCov">         10 :       addstr(out, RETS, LL(RETS));</span>
<span class="lineNum">     283 </span>            :     }
<span class="lineNum">     284 </span><span class="lineCov">         36 :     memcpy(out, POS, (LL(POS) + 1) * sizeof(char));</span>
<span class="lineNum">     285 </span>            :   }
<span class="lineNum">     286 </span><span class="lineCov">        390 : }</span>
<span class="lineNum">     287 </span>            : 
</pre>
      </td>
    </tr>
  </table>
  <br>

  <table width="100%" border=0 cellspacing=0 cellpadding=0>
    <tr><td class="ruler"><img src="../glass.png" width=3 height=3 alt=""></td></tr>
    <tr><td class="versionInfo">Generated by: <a href="http://ltp.sourceforge.net/coverage/lcov.php" target="_parent">LCOV version 1.13</a></td></tr>
  </table>
  <br>

</body>
</html>
